home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / security / namespace.init < prev    next >
Text File  |  2008-10-16  |  1KB  |  25 lines

  1. #!/bin/sh -p
  2. # It receives polydir path as $1, the instance path as $2, 
  3. # a flag whether the instance dir was newly created (0 - no, 1 - yes) in $3,
  4. # and user name in $4.
  5. #
  6. # The following section will copy the contents of /etc/skel if this is a
  7. # newly created home directory.
  8. if [ "$3" = 1 ]; then
  9.         # This line will fix the labeling on all newly created directories
  10.         [ -x /sbin/restorecon ] && /sbin/restorecon "$1"
  11.         user="$4"
  12.         passwd=$(getent passwd "$user")
  13.         homedir=$(echo "$passwd" | cut -f6 -d":")
  14.         if [ "$1" = "$homedir" ]; then
  15.                 gid=$(echo "$passwd" | cut -f4 -d":")
  16.                 cp -rT /etc/skel "$homedir"
  17.                 chown -R "$user":"$gid" "$homedir"
  18.                 mode=$(awk '/^UMASK/{gsub("#.*$", "", $2); printf "%o", and(0777,compl(strtonum("0" $2))); exit}' /etc/login.defs)
  19.                 chmod ${mode:-700} "$homedir"
  20.                 [ -x /sbin/restorecon ] && /sbin/restorecon -R "$homedir"
  21.         fi
  22. fi
  23.  
  24. exit 0
  25.